import store from 'store/index.js'

let sourecApi = 'http://192.168.2.107:9501/'

function showToast(text, icon) {
	uni.showToast({
		title: text,
		icon: icon
	});
}
const baseUrl = {
	// 上传图片的接口地址
	setUploadImg: 'http://www.shop.muliti.xyz/shop/uploads/setUploadImg',
	setShopScienceImg: 'http://www.shop.muliti.xyz/shop/shop/setShopScienceImg',

}

const getLL = () => { // 获取经纬度
	return new Promise((resolve, reject) => {
		uni.getLocation({
			type: 'wgs84',
			success: res => {
				resolve({
					longitude: res.longitude,
					latitude: res.latitude
				})
			},
			fail(e) {
				reject(e)
			}
		});
	})
}


const formatMoney = (val) => { // 处理金额
	let str = val.toFixed(2) + '';
	let intSum = str.substring(0, str.indexOf(".")).replace(/\B(?=(?:\d{3})+$)/g, ',');
	let dot = str.substring(str.length, str.indexOf("."));
	let ret = intSum + dot;
	return ret;
}

function getCaptcha(api, obj) {
	uni.request({
		url: `${sourecApi}${api}`,
		method: 'GET',
		data: {
			phone: phone
		},
		success: res => {
			console.log(res)
		},
		fail: () => {},
		complete: () => {},

	});
}

const orderStatus = (val) => {
	switch (val) {
		case 0:
			return "待支付"
			break;
		case 1:
			return "已支付"
			break;
		case 2:
			return "配送中"
			break;
		case 3:
			return "已收货"
			break;
		case 4:
			return "已评价"
			break;
		case 5:
			return "申诉中"
			break;
		case 6:
			return "退款中"
			break;
		case 7:
			return "已退款"
			break;
		case 8:
			return "已取消"
			break;
		case 9:
			return "删除"
			break;
		default:
			return "默认"
	}
}

export {
	showToast,
	getCaptcha,
	getLL,
	baseUrl,
	formatMoney,
	orderStatus
}
